package cn.tedu.jdkx.jdk5;

public class EnumDemo {
    public static void main(String[] args) {
        Season spring = Season.spring;
        //switch表达式支持枚举类型
        switch (spring){
            case spring:
                System.out.println("春游！！！");
                break;
            case summer:
                System.out.println("游泳");
                break;
            case autumn:
                System.out.println("爬山");
                break;
            case winter:
                System.out.println("打雪仗");
                break;
        }
    }
}

//枚举类
enum Season{
    //将值一一列举
    //spring--等效--public final static Season spring=new Season();
    //列举的是枚举常量(要在首行)
    spring{
        @Override
        public void n() {

        }
    },summer{
        @Override
        public void n() {

        }
    },autumn{
        @Override
        public void n() {

        }
    },winter{
        @Override
        public void n() {

        }
    };

    //属性
    int age;
    //方法
    public void m(){}

    //私有化构造方法
    private Season(){}

    //定义抽象方法
    //保证每个枚举常量都通过匿名内部类重写抽象方法
    public abstract void n();

}


//定义类---代表季节的类，创建的对象就是具体季节
//一年四季，类只能创建四个对象
/*class Season{
    //私有化的构造方法
    private Season(){}

    //创建四个对象---四个季节
    public final static Season spring=new Season();
    public final static Season summer=new Season();
    public final static Season autumn=new Season();
    public final static Season winter=new Season();
}*/











